package com.dd.ent.car.ui.widget.webview;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

/**
 * Created by dengqu on 2017/2/24.
 */

public class ObservableWebView extends WebView {
    private OnScrollChangedListener mScrollChangedListener;

    public ObservableWebView(final Context context) {
        super(context);
    }

    public ObservableWebView(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    public ObservableWebView(final Context context, final AttributeSet attrs, final int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onScrollChanged(final int l, final int t, final int oldl, final int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (mScrollChangedListener != null) {
            mScrollChangedListener.onScroll(l, t, oldl, oldt);
        }
    }

    public void setOnScrollChangedListener(final OnScrollChangedListener listener) {
        mScrollChangedListener = listener;
    }

    public interface OnScrollChangedListener {
        void onScroll(int left, int top, int oldLeft, int oldTop);
    }
}